/* Body styles removed to not conflict with Tailwind */
.hero-viewport {
  font-family: inherit;
}

/* Header Styles */
.site-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 30;
  /* Highest z-index to stay above overlay */
  padding: 1.5rem 0;
  pointer-events: none;
  /* Let clicks pass through unless on links */
  background: linear-gradient(to bottom, rgba(88, 49, 35, 0.6), transparent);
  /* Semi-transparent black background */
  backdrop-filter: blur(4px);
  /* Optional: slight blur for readability */
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
  /* Smooth pull-up animation */
}

.main-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  gap: 3rem;
}

.main-nav a {
  pointer-events: auto;
  /* Re-enable clicks for links */
  color: white;
  text-decoration: none;
  font-family: "Playfair Display";
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: -0.025em;
  text-transform: none;
  position: relative;
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

.main-nav a::after {
  content: "";
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -4px;
  left: 0;
  background-color: #be9167;
  transition: width 0.3s ease;
}

.main-nav a:hover {
  opacity: 1;
  color: #be9167;
}

.main-nav a:hover::after {
  width: 100%;
}

.hero-viewport {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height ensures bottom controls remain visible on mobile */
  overflow: hidden;
  /* This hides the video's "extra" edges */
  background: #000;
}

/* Immersive Mode Active State */
body.immersive-active {
  overflow: hidden; /* Prevent page scrolling while dragging around hero */
}

body.immersive-active .hero-viewport {
  touch-action: none; /* Disable browser's native touch gestures mapping so touchmove handles purely parallax */
}

.video-canvas {
  position: absolute;
  will-change: transform;

  /* Force a mathematically perfect 16:9 box that is guaranteed to cover 130vw/130vh */
  /* This ensures the floating text and video scale uniformly together perfectly */
  width: max(130vw, 130vh * (16/9));
  height: max(130vh, 130vw * (9/16));

  /* Absolute center alignment using margins instead of transform (since JS overwrites transform) */
  top: 50%;
  left: 50%;
  margin-left: calc(-0.5 * max(130vw, 130vh * (16/9)));
  margin-top: calc(-0.5 * max(130vh, 130vw * (9/16)));
}

.vignette-overlay {
  /* Break out of constraints entirely to act as an unmoving viewport filter */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  pointer-events: none;
  background:
    radial-gradient(circle, transparent 30%, rgba(88, 49, 35, 0.85) 120%),
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(140, 98, 76, 0.05) 10px,
      rgba(140, 98, 76, 0.05) 12px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 10px,
      rgba(140, 98, 76, 0.05) 10px,
      rgba(140, 98, 76, 0.05) 12px
    );
  opacity: 0;
  transition: opacity 1s ease;
  z-index: 5;
}

.vignette-overlay.is-visible {
  opacity: 1;
}

.parallax-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* The "buffer zone" for movement */
  transition:
    filter 1s ease,
    opacity 1s ease;
  /* Explicitly transition filter and opacity */
  filter: sepia(0.3) saturate(1.2) hue-rotate(-10deg) brightness(0.9);
  /* Default state: subtle warmth to match the "native-brown" and cultural aesthetic */
  opacity: 1;
}

/* 
  Class to be added by JS when hovering text.
  We put it on the video-container via JS, or target the video directly if simpler.
  
  Let's use a class on the video element for simplicity. 
*/
.parallax-video.is-hovered {
  filter: sepia(0.5) saturate(0.8) hue-rotate(-10deg) brightness(0.65);
  /* Darker and earthier for readability on hover */
  opacity: 0.8;
  /* Fade out to black background */
}

.hero-overlay {
  position: absolute;
  z-index: 10;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
  pointer-events: none;
  /* Allow interaction through text */
  transition: opacity 1.5s ease;
  /* Enable smooth fade out */
  opacity: 1;
}

.hero-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.hero-overlay h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(3.5rem, 10vw, 6.5rem);
  font-weight: 500;
  margin-bottom: 0.5rem;
  text-transform: none;
  letter-spacing: 3vw;
  text-shadow: 0 4px 20px rgba(88, 49, 35, 0.8);
  color: #fbf9f6;
}

.hero-overlay p {
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 0;
  text-shadow: 0 2px 10px rgba(88, 49, 35, 0.6);
  color: #fbf9f6;
  opacity: 0.9;
}

.start-btn {
  pointer-events: auto;
  margin-top: 2rem;
  padding: 0.75rem 1.75rem;
  background: rgba(190, 145, 103, 0.15);
  border: 1px solid rgba(190, 145, 103, 0.5);
  border-radius: 0.5rem;
  color: #fbf9f6;
  font-size: 0.875rem;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

.start-btn:hover {
  background: #583123;
  border-color: #583123;
  color: #fbf9f6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(88, 49, 35, 0.4);
}

/* Experience Controls Container */
.experience-controls {
  position: absolute;
  bottom: 2rem;
  right: 2rem;
  z-index: 20;
  display: flex;
  gap: 1rem;
}

/* Base button visibility */
.control-btn {
  background: transparent;
  border: 1px solid rgba(190, 145, 103, 0.4);
  color: white;
  padding: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

/* Initially hide the Back button */
#back-btn {
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
  transition:
    opacity 0.5s ease,
    transform 0.5s ease;
}

/* Show Back button when active */
#back-btn.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.control-btn:hover {
  background: #be9167;
  border-color: #be9167;
  color: #fbf9f6;
  transform: scale(1.1);
}

.control-btn svg {
  display: block;
}

/* --- Floating Caption Styles --- */
.floating-caption {
  position: absolute;
  z-index: 15;

  /* [CONFIG] EXACT HIGHLIGHT COORDINATES - Adjust these percentages to lock this element to a specific spot on the video canvas */
  top: 60%;
  left: 30%;

  /* Correct the transform so the left edge of the dot perfectly hits your assigned coordinate */
  transform: translate(-12px, 30px);

  /* Visual Styling */
  color: #fbf9f6;
  text-shadow: 0 1px 3px rgba(88, 49, 35, 0.6);
  cursor: pointer;

  /* Initial State: Hidden */
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 1.5s ease,
    transform 1.5s ease;

  /* Flexbox layout for map marker text styling */
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 15px;
}

/* State when revealed */
.floating-caption.is-visible {
  opacity: 1;
  transform: translate(
    -12px,
    -12px
  ); /* Specifically anchors the 24px wide hotspot dot precisely to its coordinate */
  pointer-events: auto;
}

/* --- Hotspot Marker --- */
.hotspot-indicator {
  position: relative;
  width: 24px;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.hotspot-dot {
  width: 8px;
  height: 8px;
  background-color: #be9167;
  border-radius: 50%;
  z-index: 2;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  transition: transform 0.3s ease;
}

.floating-caption:hover .hotspot-dot {
  transform: scale(1.3);
  background-color: #fbf9f6;
}

.hotspot-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: rgba(190, 145, 103, 0.8);
  border-radius: 50%;
  z-index: 1;
  animation: mapPulse 2s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes mapPulse {
  0% {
    transform: scale(0.8);
    opacity: 0.8;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

.caption-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  user-select: none;
  -webkit-user-select: none;
}

.caption-title {
  display: inline-block;
  position: relative;
  font-family: "Playfair Display", serif;
  font-size: 1.5rem;
  text-transform: none;
  letter-spacing: 1px;
  padding-bottom: 4px;
}

.caption-title::after {
  content: "";
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #fbf9f6;
  transition: width 0.5s ease;
}

.floating-caption:hover .caption-title::after {
  width: 100%;
}

.caption-description {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0.5px;
  margin-top: 0;
  transition: all 0.5s ease;
}

.floating-caption:hover .caption-description {
  max-height: 60px;
  /* Arbitrary limit for transition */
  opacity: 1;
  margin-top: 8px;
}

@keyframes captionFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Bariw Weave Transition --- */
.weave-transition {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh; /* Cover dynamic mobile viewport completely */
  z-index: 9999;
  display: flex;
  pointer-events: none;
}

.weave-transition.no-transition .weave-strip {
  transition: none !important;
}

.weave-strip {
  flex: 1;
  height: 100%;
  background-color: #8c624c;
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.08) 10px,
      rgba(255, 255, 255, 0.08) 12px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.08) 10px,
      rgba(255, 255, 255, 0.08) 12px
    );
  transform: translateY(-100%);
  transition: transform 0.6s cubic-bezier(0.77, 0, 0.175, 1);
  transition-delay: calc(var(--strip-index) * 0.1s);
}

.weave-transition.is-active .weave-strip {
  transform: translateY(0);
}

.weave-transition.is-exiting .weave-strip {
  transform: translateY(100%);
}

/* Scroll Indicator */
.scroll-indicator {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 20;
  color: #fbf9f6;
  text-decoration: none;
  opacity: 0.8;
  transition:
    opacity 0.5s ease,
    transform 0.3s ease;
  pointer-events: auto;
}

.scroll-indicator:hover {
  opacity: 1;
  transform: translateX(-50%) translateY(4px);
  color: #be9167;
}

.scroll-indicator.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-10px);
}

.scroll-mouse {
  width: 22px;
  height: 34px;
  border: 1.5px solid currentColor;
  border-radius: 12px;
  position: relative;
  display: flex;
  justify-content: center;
  padding-top: 6px;
}

.scroll-wheel {
  width: 2px;
  height: 6px;
  background-color: currentColor;
  border-radius: 2px;
  animation: scrollWheel 1.5s infinite;
}

.scroll-arrow {
  font-size: 1.25rem;
  animation: scrollArrow 1.5s infinite;
}

@keyframes scrollWheel {
  0% {
    transform: translateY(0);
    opacity: 1;
  }

  100% {
    transform: translateY(8px);
    opacity: 0;
  }
}

@keyframes scrollArrow {
  0% {
    transform: translateY(0);
    opacity: 0.5;
  }

  50% {
    transform: translateY(4px);
    opacity: 1;
  }

  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
}

/* --- 3D Image Slider --- */
.slider-container {
  width: 100%;
  height: 500px;
  text-align: center;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  /* Disable selection to make dragging nicer overall */
  user-select: none;
  -webkit-user-select: none;
  /* Limit pointer events so only the cards catch the drag, not the empty expanse */
  pointer-events: none;
}

/* Invisible drag zone filling the gaps behind the 3D cards, mathematically bound to the visual cards */
.slider-container::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -702px;
  width: 964px;
  z-index: 1;
  pointer-events: auto;
  cursor: grab;
}

.slider-container:active::before {
  cursor: grabbing;
}

.slider-3d {
  position: absolute;
  width: 160px;
  height: 220px;
  top: 15%;
  left: -300px;
  transform-style: preserve-3d;
  transform: perspective(1000px);
  z-index: 10;
  /* Disable selection to make dragging nicer */
  user-select: none;
  -webkit-user-select: none;
  /* Re-enable pointer events for the exact 3D footprint */
  pointer-events: auto;
  cursor: grab;
}

.slider-3d:active {
  cursor: grabbing;
}

.slider-3d .item {
  position: absolute;
  inset: 0 0 0 0;
  transform: rotateY(
      calc((var(--position) - 1) * (360 / var(--quantity)) * 1deg)
    )
    translateZ(400px);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.slider-3d:active .item {
  cursor: grabbing;
}

@media (max-width: 768px) {
  .slider-container {
    height: 380px;
  }
  .slider-container::before {
    left: -350px;
    width: 485px;
    /* Reduce the vertical touch area so empty space below/above allows normal scrolling */
    top: 15%;
    bottom: 20%;
    touch-action: none;
  }
  .slider-3d {
    width: 130px;
    height: 180px;
    left: -170px;
    touch-action: none;
  }
  .slider-3d .item {
    transform: rotateY(
        calc((var(--position) - 1) * (360 / var(--quantity)) * 1deg)
      )
      translateZ(230px);
  }
}

.slider-3d .item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
  transition:
    transform 0.3s,
    border 0.3s,
    box-shadow 0.3s;
  border: 1px solid rgba(190, 145, 103, 0.2); /* matched to brand accent1 */
  pointer-events: none; /* Prevents ghost image drag on desktop */
  -webkit-user-drag: none;
}

@media (hover: hover) {
  .slider-3d .item.js-hovered img {
    transform: scale(1.1) translateY(-10px);
    border: 2px solid #be9167; /* matched to brand accent1 */
  }
}

.slider-3d .item.is-selected img {
  transform: scale(1.1) translateY(-10px);
  border: 2px solid #be9167; /* matched to brand accent1 */
  box-shadow: 0 15px 35px rgba(190, 145, 103, 0.5);
}

.slider-3d .item > div {
  transition:
    transform 0.3s,
    opacity 0.3s;
}

/* Keep the text overlay permanently visible when selected */
.slider-3d .item.is-selected > div {
  opacity: 1 !important;
  transform: scale(1.1) translateY(-10px);
}

@media (hover: hover) {
  /* Match the overlay scale transform with the image hover transform so the gradient fully covers it */
  .slider-3d .item.js-hovered > div {
    transform: scale(1.1) translateY(-10px);
  }
}

/* Force gradient opacity on js-hovered */
.slider-3d .item.js-hovered > div {
  opacity: 1 !important;
}

/* Mobile & Responsive Adjustments */
@media (max-width: 768px) {
  .video-canvas {
    /* Explode the size for ultra-panorama on mobile but maintain mathematically perfect 16:9 ratio */
    width: max(350vw, 130vh * (16/9));
    height: max(130vh, 350vw * (9/16));

    margin-left: calc(-0.5 * max(350vw, 130vh * (16/9)));
    margin-top: calc(-0.5 * max(130vh, 350vw * (9/16)));
  }

  .parallax-video {
    /* Stop using manual scaling overrides which causes unpredictable clipping based on device */
    object-fit: cover;
    width: 100%;
    height: 100%;
    top: 0;
    position: absolute; /* Lock to the newly expanded video-canvas container */
    left: 0;
  }

  /* Vignette settings are now handled universally by the global fixed position rule */

  .main-nav ul {
    gap: 1.5rem;
    flex-wrap: wrap;
  }

  .main-nav a {
    font-size: 0.95rem;
  }

  .hero-overlay p {
    font-size: 0.85rem;
    letter-spacing: 0.08em;
  }

  .floating-caption {
    /* REMOVED bounding constraints that disrupt pinpoint mapping. 
       Use the main config variables at the top of the file to position it */
  }

  .caption-title {
    font-size: 0.95rem; /* Reduced from 1.15rem */
  }

  .caption-description {
    font-size: 0.7rem; /* Reduced base mobile description size */
    letter-spacing: 0.25px; /* Cleaned up spacing slightly for smaller text readability */
  }

  .experience-controls {
    bottom: 1rem;
    right: 1rem;
    gap: 0.5rem;
  }

  .control-btn {
    padding: 8px;
  }

  .control-btn svg {
    width: 18px;
    height: 18px;
  }

  .scroll-mouse {
    display: none;
  }

  .scroll-arrow {
    font-size: 2rem;
  }
}

/* Apply Playfair Display to all headings and big texts globally */
h1,
h2,
h3,
h4,
h5,
h6,
.big-text,
.caption-title {
  font-family: "Playfair Display", serif !important;
}
